<?php TPL::output('m/header_meta.tpl.htm'); ?>
    <style>
        .data_list {
            padding: 0 12px;
        }

        .data_list dl.users {
            height: 62px;
            padding: 10px 0;
            border-bottom: 1px solid #e4e4e4;
        }

        .data_list dl.topics {
            float: left;
            width: 25%;
            text-align: center;
            padding: 10px 0;
        }

        dl.users dt {
            width: 42px;
            height: 42px;
            border-radius: 42px;
            float: left;
            margin-right: 10px;
        }

        dl.users dt img {
            width: 42px;
            height: 42px;
            border-radius: 42px;
        }

        dl.users dd {
            width: calc(100% - 52px);
        }

        dl.users dd a {
            display: block;
            font-size: 14px;
            color: #666;
            line-height: 20px;
        }

        dl.users dd span {
            display: block;
            font-size: 12px;
            color: #999;
            line-height: 20px;
        }

        dl.topics dl dt img {
            display: block;
            width: 36px;
            height: 36px;
            border-radius: 5px;
            margin: 0 auto 7px;
        }

        dl.topics dl dd {
            text-align: center;
            font-size: 13px;
            color: #333;
        }

        dl.question {
            margin-top: 10px;
            background: #FFF;
            border-radius: 5px;
            border: 1px solid #e4e4e4;
        }
        #list_nav .active{border-bottom: 2px solid #155faa;}
.ser_class ul li {
    width: 20%;
}

    </style>

<!--搜索2-->
<div class="ser_box">
    <form id="search_form" action="m/search/" method="post">
        <div class="ser_inp">
        	<input name="q" type="text" value="<?php echo $this->keyword;?>">
        </div>
        <a href="javascript:void(0);"  onclick="document.getElementById('search_form').submit()">确定</a>
    </form>
</div>
<!--搜索2end-->
<!--关注推荐-->
<div class="gztj_tab ser_class">
	<ul id="list_nav">
    	<li class="active tab" type="all"><a href="javascript:void(0);" data-toggle="tab">全部</a></li>
        <li class="tab" type="articles"><a href="javascript:void(0);" data-toggle="tab">文章</a></li>
        <li class="tab" type="questions"><a href="javascript:void(0);" data-toggle="tab">问题</a></li>
        <li class="tab" type="topics"><a href="javascript:void(0);" data-toggle="tab">话题</a></li>
        <li class="tab" type="users"><a href="javascript:void(0);" data-toggle="tab">用户</a></li>
    </ul>
</div>
<!--关注推荐end-->
<!--推荐列表-->
    <div class="data_list border_none" style="padding: 0 12px;padding-bottom: 60px;">

</div>
<!--推荐列表end-->
    <div class="load_more" page="1" style="display: none;"><a href="#"><img src="<?php echo base_url();?>/static/mobile/images/loading.gif"></a>
    </div>

<script>
    <?php if (addslashes($this->keyword)) { ?>
    search_query = '<?php echo addslashes($this->keyword); ?>';
    <?php } else { ?>
    search_query = '<?php echo $_GET['q']; ?>';
    <?php } ?>
    split_query = '<?php echo addslashes($this->split_keyword); ?>';
    var keyword = search_query;
    var url = G_BASE_URL + '/search/ajax/search_result/';
    var is_scroll = true;
    $(".tab").each(function (i) {

        $(this).on('click', function (k) {
            var type = $(this).attr('type');
            $(this).addClass('active').siblings().removeClass('active');
            var page = parseInt($(this).attr('data-page')) || 0;
           // alert(type);
            $.ajax({
                url: url,
                type: 'GET',
                data: {page:page,search_type:type,q:keyword,is_recommend:0},
                success: function (data) {
                    $(".data_list").empty().append(data);
                }
            })
        })
    });
    $(".tab").eq(0).click();
    $(window).bind('scroll', function () {
        var page = $(".load_more").attr('page') || 0;
        var type = $("#list_nav").find('li.active').attr('type');
        if ($(document).scrollTop() == $(document).height() - $(window).height() && is_scroll) {
            page = parseInt(page) + 1;
            $.ajax({
                url: url,
                type: 'GET',
                data: {page: page, search_type: type, q: keyword, is_recommend: 0},
                beforeSend: function () {
                    $(".load_more").attr('page', page);
                    $(".load_more").show();
                },
                success: function (data) {
                    if ($.trim(data)) {
                        if ((data.split('<div class="mod-body nodata">')).length - 1){
                            is_scroll = false;
                            AWS.DingTalk.showToast(null, "暂无更多数据");
                        }else{
                            $(".data_list").append(data);
                        }
                    } else {
                        is_scroll = false;
                        AWS.DingTalk.showToast(null, "暂无更多数据");
                    }
                    return false;
                },
                complete: function () {
                    $(".load_more").hide();
                }
            })
        }
    });
        $(document).on('click',"a[type='aq']",function(k){
              var url=G_BASE_URL+$(this).attr('url');
        AWS.DingTalk.open(url);
       
    });
</script>
<script type="text/javascript">
	<?php if (addslashes($this->keyword)) { ?>
		search_query = '<?php echo addslashes($this->keyword); ?>';
	<?php } else { ?>
		search_query = '<?php echo $_GET['q']; ?>';
	<?php } ?>
	split_query = '<?php echo addslashes($this->split_keyword); ?>';
	ajax_template = 'm';

	$(function()
	{
		$('.aw-search-bar input').focus();
	});
</script>

<?php TPL::output('m/footer.tpl.htm'); ?>